{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        {include file='public:left-menu'/}
        <!--End 左侧导航-->
        <!--头部信息-->
        {include file='public:nav-header' title="商品管理" subTitle="监控列表"/}
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="hint">
                                <div class="hint-info">
                                    <h5><i class="mdi mdi-help-circle-outline"></i>操作提示</h5>
                                    <p>平台所有监控场地列表</p>
                                </div>
                            </div>
                            <div class="card-toolbar">
                                <div class="toolbar-btn-action">
                                    <a class="btn btn-label btn-theme" href="{:url('Goods/add_edit_monitor')}"><label><i class="mdi mdi-plus-box"></i></label> 添加监控</a>
                                </div>
                                <div class="card-toolbar-center">
                                    <a href="" class="table-btn btn-dark"><i class="mdi mdi-replay"></i></a>
                                    <button class="table-btn btn-theme">共{$list->total()}条记录 当前第{$list->currentPage()}页</button>
                                </div>
                                <form class="table-form" method="post" action="">
                                    <div class="table-form-group">
                                        <select name="is_open" class="input-group-select">
                                            <option value="">是否显示</option>
                                            <option value="1" {if $Request.param.is_open=='1'}selected{/if}>是</option>
                                            <option value="0" {if $Request.param.is_open=='0'}selected{/if}>否</option>
                                        </select>
                                        <input type="text" value="{$Request.param.keyword}" name="keyword"
                                               placeholder="查询监控名称">
                                        <button class="btn btn-default" type="submit">搜索</button>
                                    </div>
                                </form>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-bordered table-striped table-hover">
                                        <thead>
                                        <tr>
                                            <th style="width: 110px">操作</th>
                                            <th>监控名称</th>
                                            <th>所属分类</th>
                                            <th>主图</th>
                                            <th>是否显示</th>
                                            <th>排序</th>
                                            <th>创建时间</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {if $list->isEmpty()}
                                        <tr>
                                            <td class="no-data" colspan="50">
                                                <i class="mdi mdi-alert-decagram"></i>没有符合条件的记录
                                            </td>
                                        </tr>
                                        {else/}
                                        {volist name="$list" id="vo"}
                                        <tr>
                                            <td>
                                                <a class="table-btn btn-theme" href="{:url('Goods/add_edit_monitor',['id'=>$vo[$vo.pk]])}"><i class="mdi mdi-pencil"></i>编辑</a>
                                            </td>
                                            <td>{$vo.name}</td>
                                            <td>{$vo.cate.name}</td>
                                            <td class="img"><img title="点击图片看大图" data-toggle="tooltip" class="table-img" src="{$vo.img}"></td>
                                            <td><span data-id="{$vo[$vo.pk]}" data-field="is_open" class="open mdi {$vo.is_open==1 ? 'text-success mdi-checkbox-marked-circle-outline' : 'text-red mdi-close-circle-outline'}"> {$vo.open_text}</span>
                                            <td><input data-id="{$vo[$vo.pk]}" type="text" class="table-input" value="{$vo.sort}"></td>
                                            <td>{$vo.add_time}</td>
                                        </tr>
                                        {/volist}
                                        {/if}
                                        </tbody>
                                    </table>
                                </div>
                                <!--分页-->
                                <div class="page">
                                    {$page|raw}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript">
    $(function(){
        layer.photos({
            photos: '.img'
            ,anim: 5
        });
        $('.open').on('click', function () {
            if ($(this).hasClass('text-success')) {
                var is_open = 0;
                var add = 'text-red mdi-close-circle-outline';
                var remove = 'text-success mdi-checkbox-marked-circle-outline';
                var text = ' 否';
            } else {
                var is_open = 1;
                var add = 'text-success mdi-checkbox-marked-circle-outline';
                var remove = 'text-red mdi-close-circle-outline';
                var text = ' 是';
            }
            var id = $(this).attr('data-id');
            var obj = $(this);
            changeTableVal('monitors', 'is_open', id, is_open, function (res) {
                if (res.code == 1) {
                    obj.removeClass(remove).addClass(add).text(text);
                }
            });
        });
        $('.table-input').on('blur',function () {
            var id=$(this).attr('data-id');
            var val=$(this).val();
            if (val==''){
                showErrorMsg("请输入排序");
                return;
            }
            changeTableVal('monitors', 'sort', id, val, function (res) {
            });
        });
    });
</script>
</body>
</html>